import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * @author Jimmy Zhan WORKSTATION
 * @since 2023/8/30 20:33
 * 说明：
 */

public class Main2 {
    public static int dfs(int l, int r, int[][] dp, int[] a, int[] sum) {
        if (dp[l][r] != -1) {
            return dp[l][r];
        }
        if (l == r) {
            dp[l][l] = a[l];
            return a[l];
        }
        int max = Integer.MIN_VALUE;
        for (int i = l+1; i <= r; i++) {
            max = Math.max(max, sum[r]-sum[l-1]-dfs(i,r,dp,a,sum));
        }
        for (int i = r-1; i >= l; i--) {
            max = Math.max(max, sum[r]-sum[l-1]-dfs(l,i,dp,a,sum));
        }
        max = Math.max(max, sum[r] - sum[l-1]);
        dp[l][r] = max;
        return max;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] temp = new int[n+10];
        List<Integer> list = new ArrayList<>();
        for (int i = 1; i <= n; i++) {
            temp[i] = sc.nextInt();
        }
        int[] sum = new int[210];
        int[][] dp = new int[210][210];
        for (int i = 0; i < dp.length; i++) {
            Arrays.fill(dp[i], -1);
        }
        sum[1] = temp[1];
        for (int i = 2; i <= n; i++) {
            sum[i] = sum[i-1] + temp[i];
        }
        System.out.println(2*dfs(1, n, dp, temp, sum) - sum[n]);
    }
}











